//
//  ChartTableViewCell.swift
//  beegin2
//
//  Created by zsy on 16/4/4.
//  Copyright © 2016年 kszz. All rights reserved.
//

import UIKit

enum chartType{

    case sumLine,vitaminBar,elementsBar
}

class ChartTableViewCell: UITableViewCell,UUChartDataSource {

    @IBOutlet weak var chartView: UUChart!
    
    @IBOutlet weak var titleLable: UILabel!

   
    var showType:chartType = .sumLine{
    
        didSet{
        
            if showType == .sumLine{
            
                chartView.chartStyle = .Line
                
            }else{
            
                chartView.chartStyle = .Bar
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        chartView.dataSource = self
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
  //pragma mark - @required

    func chartConfigAxisXLabel(chart: UUChart!) -> [AnyObject]! {
        
        switch showType{
        
        case .sumLine:
            return ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
        case .vitaminBar:
            return ["A","B1","B2","B6","B12","C","D","E","K"]
        case .elementsBar:
            return ["钙","铬","铜","氟","碘","钾","铁","钠","锰","硒","钼","锌","磷","镁","氯"]
        }
        
    }
    
    func chartConfigAxisYValue(chart: UUChart!) -> [AnyObject]! {
        
        switch showType{
            
        case .sumLine:
            return [["130","710","200","500","900","400","120"]]
        case .vitaminBar:
            return [["18","67","90","45","66","21","33","70","22"]]
        case .elementsBar:
            return [["32","55","33","11","37","31","90","89","22","44","24","32","38","89","66"]]
        }
    }
    //pragma mark - @optional
    //颜色数组
    func chartConfigColors(chart: UUChart!) -> [AnyObject]! {
        
        switch showType{
            
        case .sumLine:
            return [UIColor(red: 54 / 255, green: 188 / 255, blue: 155 / 255, alpha: 250 / 255)]
        case .vitaminBar:
            return [UIColor(red: 252 / 255, green: 110 / 255, blue: 80 / 255, alpha: 250 / 255)]
        case .elementsBar:
            return [UIColor(red: 78 / 255, green: 193 / 255, blue: 233 / 255, alpha: 250 / 255)]
        }
    }
    //判断显示横线条
    func chart(chart: UUChart!, showHorizonLineAtIndex index: Int) -> Bool {
        
        return true
    }
    //判断显示最大最小值
    func chart(chart: UUChart!, showMaxMinAtIndex index: Int) -> Bool {
        
        return true
    }
}
